package com.middle.experiment01.mapper;

import com.middle.experiment01.entity.Student;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface StudentMapper {
    @Select("select id, name, gender, phone, major from student where id = #{id}")
    Student getById(Long id);

    @Select("select id, name, gender, phone, major from student")
    List<Student> pageAllStudent();

    @Insert("insert into student (id,name,gender,phone,major)" +
            "values (#{id},#{name},#{gender},#{phone},#{major})")
    void insert(Student student);

    @Delete("delete from middleware.student where id=#{id}")
    void deleteById(int id);

    void update(Student student);
}
